package com.itheima;

import com.itheima.dao.BookDao;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class AppForLifeCycle {
    public static void main( String[] args ) {

        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
//        设置关闭钩子，关闭虚拟器之前，把容器先关掉
        context.registerShutdownHook();

        BookDao bookDao = (BookDao) context.getBean("bookDao");
        bookDao.save();

//        关闭容器比较暴力
//        context.close();



    }
}
